package cn.iocoder.yudao.module.biz.dal.mysql.expand.targets.channel;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.biz.dal.dataobject.expand.targets.channel.ExpandTargetChannelDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.biz.controller.admin.expand.targets.channel.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 拓展目标_渠道 Mapper
 *
 * @author 超级管理员
 */
@Mapper
public interface ExpandTargetChannelMapper extends BaseMapperX<ExpandTargetChannelDO> {

    default PageResult<ExpandTargetChannelDO> selectPage(ExpandTargetChannelPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ExpandTargetChannelDO>()
                .likeIfPresent(ExpandTargetChannelDO::getName, reqVO.getName())
                .eqIfPresent(ExpandTargetChannelDO::getLocation, reqVO.getLocation())
                .eqIfPresent(ExpandTargetChannelDO::getAddress, reqVO.getAddress())
                .likeIfPresent(ExpandTargetChannelDO::getContactName, reqVO.getContactName())
                .eqIfPresent(ExpandTargetChannelDO::getContactNumber, reqVO.getContactNumber())
                .eqIfPresent(ExpandTargetChannelDO::getRelationLevel, reqVO.getRelationLevel())
                .eqIfPresent(ExpandTargetChannelDO::getChannelLevel, reqVO.getChannelLevel())
                .eqIfPresent(ExpandTargetChannelDO::getMainProduct, reqVO.getMainProduct())
                .eqIfPresent(ExpandTargetChannelDO::getCountMethod, reqVO.getCountMethod())
                .eqIfPresent(ExpandTargetChannelDO::getRevenueDescribe, reqVO.getRevenueDescribe())
                .eqIfPresent(ExpandTargetChannelDO::getTransferIntroduceSituation, reqVO.getTransferIntroduceSituation())
                .eqIfPresent(ExpandTargetChannelDO::getGovSource, reqVO.getGovSource())
                .eqIfPresent(ExpandTargetChannelDO::getPersonalSource, reqVO.getPersonalSource())
                .eqIfPresent(ExpandTargetChannelDO::getBackground, reqVO.getBackground())
                .eqIfPresent(ExpandTargetChannelDO::getBusinessSituation, reqVO.getBusinessSituation())
                .eqIfPresent(ExpandTargetChannelDO::getGrowProcess, reqVO.getGrowProcess())
                .eqIfPresent(ExpandTargetChannelDO::getAdvantage, reqVO.getAdvantage())
                .eqIfPresent(ExpandTargetChannelDO::getSpecialDescribe, reqVO.getSpecialDescribe())
                .betweenIfPresent(ExpandTargetChannelDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(ExpandTargetChannelDO::getOwnerUserId, reqVO.getOwnerUserId())
                .orderByDesc(ExpandTargetChannelDO::getId));
    }

    /**
     * 检查拓展目标_客户是否存在
     * @param name
     * @return 存在返回1，不存在返回0
     */
    Integer checkExistByName(@Param("name") String name);

}